#pragma once

#include "common/common.h"
#include "Core/TCFixedString.h"
#include "string/stringoutput.h"
#include "Core/TCFixedBuffer.h"
#include "testlibpilo.h"

template <typename T>
INT32 ValidateBufferObjectInformation(const T& fixedBuffer, size_t cap, size_t dataSize, size_t rp, size_t rv, size_t wp, size_t wv)
{
    size_t bufferLength = fixedBuffer.internalBufferLength();
    size_t datasize = fixedBuffer.dataSize();
    size_t readPos = fixedBuffer.indexForReading();
    size_t writePos = fixedBuffer.indexForWriting();
    size_t readAvail = fixedBuffer.readAwailable();
    size_t writeAvail = fixedBuffer.writeAwaiable();

    if (rv * fixedBuffer.elementSize() != dataSize) {
        return -10001;
    }
    if ((rv == 0) && (rp != MC_INVALID_SIZE)) {
        return -10002;
    }
    if ((wv == 0) && (wp != MC_INVALID_SIZE)) {
        return -10003;
    }

    if (bufferLength != cap) {
        return -1;
    }
    if (datasize != dataSize) {
        return -2;
    }
    if (readPos != rp) {
        return -3;
    }
    if (writePos != wp) {
        return -4;
    }
    if (readAvail != rv) {
        return -5;
    }
    if (writeAvail != wv) {
        return -6;
    }
    return 0;
}
